Add support for raw + af_packet sockets#63
Add support for raw + af_packet sockets#63danielinux wants to merge 13 commits intowolfSSL:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds raw IP socket and AF_PACKET-style packet socket support to wolfIP, including POSIX preload shim enhancements and new example utilities for pinging via the new socket types.
Changes:
- Add RAW and PACKET socket types to the wolfIP socket API, including send/recv/bind/connect/poll support.
- Extend the POSIX LD_PRELOAD BSD socket shim with
ioctl()handling for interface/ARP queries needed by packet sockets. - Add new
raw_ping/packet_pingexamples and run them in CI.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
wolfip.h |
Adds socket constants, socket marks, and sockaddr_ll support plus ARP lookup API. |
src/wolfip.c |
Implements raw sockets + packet sockets, routing/ARP for raw TX, and capture paths for RX. |
src/test/unit/unit.c |
Adds unit tests covering raw/packet socket send/recv behaviors. |
src/test/raw_ping.c |
New raw-socket ping example for CI/manual testing. |
src/test/packet_ping.c |
New AF_PACKET ping example using ioctl-derived interface info. |
src/port/posix/bsd_socket.c |
Adds ioctl() interception and fd bookkeeping for raw/packet sockets. |
config.h |
Enables raw/packet sockets by default and sets default max counts. |
Makefile |
Builds the new ping example binaries. |
.github/workflows/linux.yml |
Runs raw_ping and packet_ping under LD_PRELOAD in CI. |
Comments suppressed due to low confidence (2)
src/test/raw_ping.c:55
- The checksum helper handles odd-length buffers incorrectly: for a trailing byte it should be added as the high-order byte of the final 16-bit word (i.e.,
byte << 8, zero-padded), not as a low-order byte. This matches how Internet checksums are computed (and how the stack’s checksum helpers handle odd lengths).
if (len == 1) {
sum += *(unsigned char *)buf;
}
src/test/packet_ping.c:99
- The checksum helper adds the trailing byte for odd-length buffers without shifting it into the high-order position of the final 16-bit word. For correctness with arbitrary payload sizes, treat the last byte as
byte << 8(zero-padded) whenlenis odd.
if (len == 1) {
sum += *(unsigned char *)buf;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add support for raw sockets and packet sockets. - Added support for BSD wrapper in posix systems. - Added 'raw_ping' and 'packet_ping' examples to craft ICMP echo requests / receive replies using the new sockets - Added automated tests to github workflow
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #63
Scan targets checked: wolfip-bugs, wolfip-compliance, wolfip-defaults, wolfip-mutation, wolfip-proptest, wolfip-src
Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #ifndef WOLF_POSIX | ||
| #define IPSTACK_SOCK_STREAM 1 | ||
| #define IPSTACK_SOCK_DGRAM 2 | ||
| #define IPSTACK_SOCK_RAW 3 |
There was a problem hiding this comment.
suggestion: We should list supported socket types in the README.md.
Add support for raw sockets and packet sockets.
Superseeds #10